package com.neusoft.resturant.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.resturant.common.utils.PageResult;
import com.neusoft.resturant.common.utils.PageUtils;
import com.neusoft.resturant.entity.ResThumbup;
import com.neusoft.resturant.mapper.ResThumbupMapper;
import com.neusoft.resturant.service.IResThumbupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 点赞Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-11
 */
@Service
public class ResThumbupServiceImpl implements IResThumbupService
{
    @Autowired
    private ResThumbupMapper resThumbupMapper;

    /**
     * 查询点赞
     * 
     * @param id 点赞主键
     * @return 点赞
     */
    @Override
    public ResThumbup selectResThumbupById(Long id)
    {
        return resThumbupMapper.selectResThumbupById(id);
    }

    /**
     * 查询点赞列表
     * 
     * @param resThumbup 点赞
     * @return 点赞
     */
    @Override
    public List<ResThumbup> selectResThumbupList(ResThumbup resThumbup)
    {
        return resThumbupMapper.selectResThumbupList(resThumbup);
    }

    @Override
    public PageResult selectResThumbupList2(ResThumbup resThumbup, Integer pageNum, Integer pageSize) {
        //1、分页从数据库中查询
        PageHelper.startPage(pageNum, pageSize);
        List<ResThumbup> resThumbups = resThumbupMapper.selectResThumbupList(resThumbup);
        //System.out.println(resThumbups.toString());
        //2、对返回值进行判断
        if (resThumbups.size()==0){
            return null;
        }
        //3、对查询的结果进行封装
        PageInfo<ResThumbup> thumbupPageInfo = new PageInfo<>(resThumbups);
        PageResult pageResult = PageUtils.getPageResult(thumbupPageInfo);

        return pageResult;

    }

    /**
     * 新增点赞
     * 
     * @param resThumbup 点赞
     * @return 结果
     */
    @Override
    public int insertResThumbup(ResThumbup resThumbup)
    {
        return resThumbupMapper.insertResThumbup(resThumbup);
    }

    /**
     * 修改点赞
     * 
     * @param resThumbup 点赞
     * @return 结果
     */
    @Override
    public int updateResThumbup(ResThumbup resThumbup)
    {
        return resThumbupMapper.updateResThumbup(resThumbup);
    }

    /**
     * 批量删除点赞
     * 
     * @param ids 需要删除的点赞主键
     * @return 结果
     */
    @Override
    public int deleteResThumbupByIds(Long[] ids)
    {
        return resThumbupMapper.deleteResThumbupByIds(ids);
    }

    /**
     * 删除点赞信息
     * 
     * @param id 点赞主键
     * @return 结果
     */
    @Override
    public int deleteResThumbupById(Long id)
    {
        return resThumbupMapper.deleteResThumbupById(id);
    }


}
